package com.itheima.zuoye2;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.Random;

public class Demo02 {
    public static void main(String[] args) {
        //创建random随机数对象 生成红色6个号码
        Random rm = new Random();

        //创建hashset保存红球
        HashSet<Integer> hs = new HashSet<>();

        //循环判断红球数量是否小于6个
        while(hs.size()<6){
            //如果小于6个就再生产成
            int numb = rm.nextInt(33)+1;
            hs.add(numb);
        }

        //创建list集合
        ArrayList<Integer> list = new ArrayList<>();
        for (Integer integer : hs) {
            list.add(integer);
        }
        Collections.sort(list);
        int blue = rm.nextInt(16)+1;
        System.out.println("双色球中间号码：");
        System.out.println("红球是：");
        for (Integer red : list) {
            System.out.println(red+"");
        }
        System.out.println();
        System.out.println("蓝球是："+blue);
    }
}
